finding the greatest common divisor